package merge

import (
	"game/game-design-v.xnanz/gen"
	"strings"
)

type CatalogArgs struct {
	TemplateFile string
	SourceHome   string
	Args         map[string]string
}

func NewCatalogArgs(args []string) *CatalogArgs {
	var catalogArgs CatalogArgs
	catalogArgs.Args = make(map[string]string)
	for _, v := range args {
		parts := strings.Split(v, " ")
		if strings.HasPrefix(v, "-template") {
			catalogArgs.TemplateFile = parts[1]

		} else if strings.HasPrefix(v, "-sourcehome") {
			catalogArgs.SourceHome = parts[1]

		} else if strings.HasPrefix(v, "-arg") {
			catalogArgs.Args[parts[1]] = parts[2]

			gen.Params[parts[1]] = parts[2]
		}
	}
	return &catalogArgs
}
